import allure
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait

from src.PO.base import Base


class EditPage(Base):
    __NAME=(By.CSS_SELECTOR,".app-container>div:nth-child(1)>div>.el-form>div:nth-child(2)>div>div>.el-input__inner")
    __REFRESH_=(By.XPATH,"//*[text()='更新商品']")
    __REFRESH_NAME_=(By.XPATH,"//*[text()='abccbaab589658']")

    def refresh_product(self):
        from src.PO.product_list_page import ProductListPage
        with allure.step("修改名称"):
            self.driver.find_element(*self.__NAME).send_keys(Keys.CONTROL, 'a')
            self.find_and_send(*self.__NAME, text="abccbaab589658")
        with allure.step("点击更新商品,跳转商品列表界面"):
            self.find_and_click(*self.__REFRESH_)
            WebDriverWait(self.driver, 10).until(expected_conditions.visibility_of_element_located((self.__REFRESH_NAME_)))
        return ProductListPage(self.driver)
    # def product_list(self):
    #     with allure.step("查找商品列表"):
    #         pd_list = self.find(By.CSS_SELECTOR,".el-table__body>tbody>tr>td:nth-child(3)")
    #     return pd_list
